//
//  CustomsSearchBtn.m
//  AAIM
//
//  Created by 远的小布丁 on 2019/12/15.
//  Copyright © 2019 AAIM. All rights reserved.
//

#import "CustomsSearchBtn.h"

@implementation CustomsSearchBtn

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self addSubview:self.customImageView];
        [self addSubview:self.nameLabel];
        [self addSubview:self.line];
        [self setUI];
    }
    return self;
}

- (void)setUI{
    [_customImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(15.f);
        make.centerY.equalTo(self.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.customImageView.mas_right).offset(24.f);
        make.right.equalTo(self.mas_right).offset(-15.f);
        make.centerY.equalTo(self.mas_centerY);
    }];
    [_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.mas_bottom);
        make.left.equalTo(self.nameLabel.mas_left);
        make.right.equalTo(self.nameLabel.mas_right);
        make.height.offset(1.f);
    }];
}

-(UIImageView *)customImageView{
    if (!_customImageView) {
        _customImageView = [[UIImageView alloc]init];
        _customImageView.image = [UIImage imageNamed:@"搜索中"];
        _customImageView.layer.cornerRadius = 5;
        _customImageView.layer.masksToBounds = YES;
        
    }
    return _customImageView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]init];
        _nameLabel.font = kMainFont(14.f);
    }
    return _nameLabel;
}

- (UIView *)line{
    if (!_line) {
        _line = [UIView new];
    }
    return _line;
}

@end
